import { createRouter, createWebHistory } from "vue-router";
import Layout from "@/layouts/Layout.vue";
import Login from "@/views/Login.vue";

const routes = [
  {
    path: "/login",
    name: "Login",
    component: Login,
    meta: { title: "登录" },
  },
  {
    path: "/",
    component: Layout,
    meta: { requiresAuth: true },
    children: [
      {
        path: "",
        name: "Dashboard",
        component: () => import("@/views/Dashboard.vue"),
        meta: { title: "首页" },
      },
      {
        path: "goods",
        name: "goods",
        meta: { title: "商品管理" },
        children: [
          {
            path: "list",
            component: () => import("@/views/goods/Index.vue"),
            meta: { title: "商品列表" },
          },          
          {
            path: "update",
            component: () => import("@/views/goods/Update.vue"),
            meta: { title: "修改商品" },
          },
          {
            path: "sku",
            component: () => import("@/views/SKU/Index.vue"),
            meta: { title: "SKU管理" },
          },
          {
            path: "category",
            component: () => import("@/views/category/Index.vue"),
            meta: { title: "分类管理" },
          },
          {
            path: "comment",
            component: () => import("@/views/goods/Comment.vue"),
            meta: { title: "评论管理" },
          },
        ],
      },
      {
        path: "orders",
        name: "Orders",
        meta: { title: "订单管理" },
        children: [
          {
            path: "list",
            component: () => import("@/views/orders/Index.vue"),
            meta: { title: "订单列表" },
          },
          {
            path: "refund",
            component: () => import("@/views/orders/Refund.vue"),
            meta: { title: "退款管理" },
          },
        ],
      },
      {
        path: "users",
        name: "Users",
        meta: { title: "用户管理" },
        children: [
          {
            path: "list",
            component: () => import("@/views/users/Index.vue"),
            meta: { title: "用户列表" },
          },
          {
            path: "analysis",
            component: () => import("@/views/users/Analysis.vue"),
              meta: { title: "用户分析" },
          },
        ],
      },
      {
        path: "marketing",
        name: "Marketing",
        meta: { title: "营销管理" },
        children: [
          {
            path: "coupon",
            component: () => import("@/views/marketing/Coupon.vue"),
            meta: { title: "优惠券管理" },
          },
          {
            path: "activity",
            component: () => import("@/views/marketing/Activity.vue"),
            meta: { title: "活动管理" },
          },
        ],
      },
      {
        path: "content",
        name: "Content",
        meta: { title: "内容管理" },
        children: [
          {
            path: "banner",
            component: () => import("@/views/content/Banner.vue"),
            meta: { title: "轮播图管理" },
          },
          {
            path: "announcement",
            component: () => import("@/views/content/Announcement.vue"),
            meta: { title: "公告管理" },
          },
        ],
      },
      {
        path: "statistics",
        name: "Statistics",
        component: () => import("@/views/Statistics.vue"),
        meta: { title: "数据统计" },
      },
      {
        path: "mallSetting",
        name: "mallSetting",
        meta: { requiresAuth: true, title: "商城设置" },
        children: [
          {
            path: "brand",
            name: "Brand",
            component: () => import("@/views/Brand/Index.vue"),
            meta: { title: "品牌管理" },
          },
        ],
      },
      {
        path: "settings",
        name: "Settings",
        meta: { requiresAuth: true, title: "系统设置" },
        children: [
          {
            path: "admins",
            name: "AdminManagement",
            component: () => import("@/views/admins/Index.vue"),
            meta: { title: "管理员管理" },
          },
          {
            path: "roles",
            name: "RoleManagement",
            component: () => import("@/views/roles/Index.vue"),
            meta: { title: "角色管理" },
          },
          {
            path: "menu",
            component: () => import("@/views/menu/Index.vue"),
            meta: { title: "菜单管理" },
          },
          {
            path: "permissions",
            name: "PermissionManagement",
            component: () => import("@/views/permissions/Index.vue"),
            meta: { title: "权限管理" },
          },
        ],
      },
      {
        path: "profile",
        name: "Profile",
        component: () => import("@/views/Profile.vue"),
        meta: { title: "个人信息" },
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;
